<template>
  <div id="app">
    <router-view />

    <van-tabbar v-if="isShow" route active-color="rgb(195, 85, 89)">
      <van-tabbar-item replace to="/home" icon="home-o"> home </van-tabbar-item>
      <van-tabbar-item replace to="/topic" icon="description">
        topic
      </van-tabbar-item>
      <van-tabbar-item replace to="/category" icon="apps-o">
        category
      </van-tabbar-item>
      <van-tabbar-item replace to="/cart" icon="shopping-cart-o">
        cart
      </van-tabbar-item>
      <van-tabbar-item replace to="/my" icon="friends-o"> my </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: true,
    };
  },
  watch: {
    $route: function (to, from) {
      // $route 监听路由变化
      // to 代表需要去的路径
      // from  代表来自于哪个路径
      console.log(to, from);
      if (to.meta.isFootShow == false) {
        this.isShow = false;
      } else {
        this.isShow = true;
      }
    },
  },
  created() {
    localStorage.setItem("openId", "18771713497");
  },
};
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
